package com.jeasonzhao.commons.parser.expression;

public class SyntaxArrayNode extends SyntaxNode
{
    private SyntaxNodeCollection subItems = null;
    public SyntaxArrayNode()
    {
    }

    public SyntaxArrayNode(SyntaxNodeCollection items)
    {
        subItems = items;
    }
    public void replaceVariableName(INameConvertor map)
    {
        for(int n = 0;null != subItems && n < subItems.size();n++)
        {
            subItems.get(n).replaceVariableName(map);
        }

    }
    public ValuePair eval(IEvalProvider provider)
        throws EvalException
    {
        Object[] ret = new Object[null == subItems ? 0 : subItems.size()];
        for(int n = 0;null != subItems && n < subItems.size();n++)
        {
            ret[n] = subItems.get(n).eval(provider);
        }
        return new ValuePair(ret);
    }
    public String getExpression()
    {
        StringBuffer buf=new StringBuffer();
        buf.append('[');
        for(int n=0;null!=this.subItems &&n<this.subItems.size();n++)
        {
            buf.append(this.subItems.get(n).getExpression());
        }
        buf.append(']');
        return buf.toString();
    }
}
